cmake_minimum_required(VERSION 3.10)

project(WebServer C CXX)

if(NOT CMAKE_BUILD_TYPE)
  set(CMAKE_BUILD_TYPE "Release")
endif()

include_directories(
  Base 
  Http
  Reactor
)

SET(CXX_FLAGS
  -g
  -std=c++11
)

string(REPLACE ";" " " CMAKE_CXX_FLAGS "${CXX_FLAGS}")
string(TOUPPER ${CMAKE_BUILD_TYPE} BUILD_TYPE)

set(CMAKE_CXX_COMPILER "g++")
set(CMAKE_CXX_FLAGS_DEBUG "-O0")
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG")
# set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address -g")
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -g")

find_package(Threads REQUIRED)

message(STATUS "CXX_FLAGS = " ${CMAKE_CXX_FLAGS} " " ${CMAKE_CXX_FLAGS_${BUILD_TYPE}})

aux_source_directory(Base SRC_LIST1)
aux_source_directory(Http SRC_LIST2)
aux_source_directory(Reactor SRC_LIST5)

set(OUTPUT_NAME "webserver")

set (EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR})

add_executable(${OUTPUT_NAME} main.cpp ${SRC_LIST1} ${SRC_LIST2} ${SRC_LIST5})
target_link_libraries(${OUTPUT_NAME} pthread)